package cn.wizzer.app.crown.commons.websocket.main.start;

import org.nutz.log.Log;
import org.nutz.log.Logs;

/**
 * @author 22099
 * 创建线程启动tcpServer
 */
public class TcpServerStarter extends Thread {

    private static final Log log = Logs.get();

    static final TcpServerStarter THAT = new TcpServerStarter();

    private TcpServerStarter() {
    }

    private TcpServer tcpServer;

    public static TcpServerStarter instance() {
        return THAT;
    }

    public TcpServerStarter setTcpServer(TcpServer tcpServer) {
        this.tcpServer = tcpServer;
        return this;
    }

    @Override
    public void run() {
        try {
            tcpServer.start();
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }

    static {
//        TcpServer tcpServer = TcpServer.instance(8091);
//        TcpServerStarter.instance().setTcpServer(tcpServer).start();
    }

    public static void main(String[] args) {
        System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
        TcpServer tcpServer = TcpServer.instance(8091);
        TcpServerStarter.instance().setTcpServer(tcpServer).start();
    }
}
